setwd("/Users/jackpaine/Box Sync/Colonial Peace")
data <- read.csv("tablea15_data.csv", header = TRUE)
library(wfe)

###Table A.15. Weighted Fixed Effects Estimator###
##Panel A. Post-independence vs. colonial rule
#Democracy
a1 <- wfe(D_demo~L_independent, data = data, treat = "L_independent", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(a1)
#War
a2 <- wfe(cow_war~L_independent, data = data, treat = "L_independent", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(a2)
#Revenues
a3 <- wfe(rev_growth~L_independent, data = data, treat = "L_independent", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(a3)
#Income
a4 <- wfe(econ_growth~L_independent, data = data, treat = "L_independent", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(a4)

##Panel B. Autonomous vs. non-autonomous colonial rule
#Democracy
b1 <- wfe(D_demo~L_autonomous, data = subset(data, L_independent==0), treat = "L_autonomous", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(b1)
#War
b2 <- wfe(cow_war~L_autonomous, data = subset(data, L_independent==0), treat = "L_autonomous", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(b2)
#Revenues
b3 <- wfe(rev_growth~L_autonomous, data = subset(data, L_independent==0), treat = "L_autonomous", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(b3)
#Income
b4 <- wfe(econ_growth~L_autonomous, data = subset(data, L_independent==0), treat = "L_autonomous", unit.index = "ccode", time.index="year", method = "unit", qoi = "ate", hetero.se=TRUE, auto.se=TRUE,White = TRUE, White.alpha = 0.05,estimator="did")
summary(b4)